package Model;

public class Helicopter {
	private double posX, posY;
	private double dirX, dirY;
	private double lookX, lookY;
	private boolean zichtbaar, manouvreerbaar;
	private double wiekHoek;
	
	
	public double getWiekHoek() {
		return wiekHoek;
	}

	public Helicopter(double posX, double posY) {
		this.setPosX(posX);
		this.setPosY(posY);
		lookX = 0;
		lookY = 1;
	}

	public void move(double x, double y) {

		// double speed = Math.sqrt(dirX * dirX + dirY * dirY)*100;
		// double newSpeed = Math.sqrt((dirX + x) * (dirX + x) + (dirY + y) *
		// (dirY + y))*100;
		if(!manouvreerbaar) return;
		if (Math.abs(dirY + y) > 1) {
			if (dirY < 0)
				dirY = -1;
			else
				dirY = 1;
		} else {
			dirY += y;
		}

		if (Math.abs(dirX + x) > 1) {
			if (dirX < 0)
				dirX = -1;
			else
				dirX = 1;
		} else {
			dirX += x;
		}

		if (dirX != 0 || dirY != 0) {
			lookX = dirX;
			lookY = dirY;
		}

	}

	public void setZichtbaar(boolean setZichtbaar) {
		zichtbaar = setZichtbaar;
	}

	public void setManouvreerbaar(boolean setManouvreerbaar) {
		manouvreerbaar = setManouvreerbaar;
	}

	public double getDirX() {
		return dirX;
	}

	public double getDirY() {
		return dirY;
	}
	
	public double getLookX() {
		return lookX;
	}

	public double getLookY() {
		return lookY;
	}

	public void step() {
		posX += dirX;
		posY += dirY;
		wiekHoek += 5;
		if(wiekHoek > 360)
			wiekHoek = 0;
	}

	public void setPosX(double posX) {
		this.posX = posX;
	}

	public double getPosX() {
		return posX;
	}

	public void setPosY(double posY) {
		this.posY = posY;
	}

	public double getPosY() {
		return posY;
	}

	public void stop(double amount) {
		dirX *= 1 - amount;
		dirY *= 1 - amount;
	}

	public boolean isManouvreerbaar() {
		return manouvreerbaar;
	}

	public boolean isZichtbaar() {
		return zichtbaar;
	}
	
	public boolean checkBounds()
	{
		boolean binnen = true;
		if(posX < 0 || posY < 0 || posX > 800 || posY > 800)
		{
			binnen = false;
		}
		return binnen;
	}
}
